home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Demos
/
A.D. Software
/
OOFILE
/
Buildable, limited OOFILE
/
samples
/
ooftst02.inc
< prev
next >
Wrap
Text File
|
1996-03-31
|
2KB
|
91 lines
// included in ooftst2, 3, 4, 6, 9 & 15
DECLARE_REF(dbPatients)
DECLARE_SET(dbVisits)
DECLARE_CLASS(dbPatients)
dbChar LastName, Othernames;
dbVisitsSet Visits;
dbLong PatientNo;
dbLong Salary;
dbPatients() :
LastName(40, "Last Name", kIndexed),
Othernames(80, "Other names", kIndexed),
PatientNo("PatientNo", kIndexNoDups),
Salary("Salary", kIndexed)
{
Visits.joinField(PatientNo);
};
// my own data entry procedures
void Add(const char *lname, const char *oname, const long salary);
void AddVisit(const char* visitDate, const char* why);
void AddTestData();
};
DECLARE_CLASS(dbVisits)
dbPatientsRef Patient;
dbLong PatientNo;
dbDate VisitDate;
dbChar Why;
dbVisits() :
PatientNo("PatientNo", kIndexed),
VisitDate("VisitDate", kIndexed),
Why(200, "Reason for Visit", kIndexCompress)
{
Patient.joinField(PatientNo);
};
};
void dbPatients::Add(const char *lname, const char *oname, const long salary)
{
newRecord();
LastName = lname;
Othernames = oname;
Salary = salary;
PatientNo = sequenceNumber();
saveRecord();
}
void dbPatients::AddVisit(const char* visitDate, const char* why)
{
Visits->newRecord();
Visits->VisitDate = visitDate;
Visits->Why = why;
}
void dbPatients::AddTestData()
{
// yes, if using SmartHeap debugging the following can take long enough to make folks wonder
// there are a *lot* of places where OOFILE calls SmartHeap to check memory
cout << "Generating new test records..." << flush;
Add("Smith", "John", 20000);
AddVisit("1/10/1994", "Sore Knee");
AddVisit("14/10/1994", "Measles");
saveRecord();
Add("DENT", "Trissa", 99999);
AddVisit("23-11-1994", "Flu");
saveRecord();
Add("Dent", "Andy", 50000);
AddVisit("4.10.1994", "Flu");
saveRecord();
Add("Taylor", "Ken", 75000);
cout << endl << endl;
}
// global variables that define the database using the above classes
dbConnect_ctree theDB;
dbPatients Patients;
dbVisits Visits;
dbRelationship PatientVisits(Patients.Visits, Visits.Patient);